<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    <div class="msg"></div>
    <textarea id="txt"></textarea>
    <input type="button" id="btn" value="发送">
</body>
<script>
    var omsg = document.querySelector(".msg");
    var otxt = document.querySelector("#txt");
    var obtn = document.querySelector("#btn");

    var arr = ["你好", "abc", "123"];

    obtn.onclick = function(){

        var str = otxt.value;

        // var regStr = "";
        // for(var i=0;i<arr.length;i++){
        //     regStr += arr[i] + "|"
        // }
        // regStr = "(" + regStr.slice(0, -1) + ")+";
        
        var regStr = arr.join("|");
        regStr = "(" + regStr + ")+";

        var reg = new RegExp(regStr, "g");

        omsg.innerHTML = str.replace(reg, "***");

    }



    
</script>
</html>